// 可索引接口：对数组、对象的约束
interface UserArr {
  [index:number]: string
}
var arr:UserArr = ['aaa', 'bbb']
console.log(arr[0])

interface UserObj {
  [index:string]: string
}
var obj:UserObj = {name: "张三"}

// 类类型接口：对类的约束（和抽象类相似）
interface Animal {
  name: string;
  eat(str:string): void;
}
class Dog implements Animal {
  name: string;
  constructor(name:string) {
    this.name = name
  }
  eat() {
    console.log(this.name + '吃粮食');
  }
}
var d = new Dog('小黑')

export {}